<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
   <%
		String base = request.getContextPath();
		request.setAttribute("base", base);
	%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="${base}/resources/js/jquery-3.2.1.min.js"></script>
<script type="text/javascript">
function change1(oneSelf){
	$("input[name=tr1]").each(function(){
		$(this).attr('checked',oneSelf.checked);
	})
}
function submit(){
	var arr=new Array();
	var i=0;
	$("input[name=tr1]:checked").each(function(){
		arr[i]=$(this).val();
		i++;
	})
	if(arr.length>0){
		$.ajax({
			url:"${base}/confirm",
			data:{"arr":arr},
			type:'post',
			success:function(data){
			    if(data=="success"){
			    	alert("购买成功");
			    	location.href="${base}/selectOrder";
			    }
			}		
		})
	}else
		alert("请最少选择1条");
}
</script>
</head>
<body>
	<div>
		<table>
			<c:forEach var="order" items="${orderList}">
				<tr>
					<td><input type="checkbox" name="tr1" value="${order.orderid}"/></td>
					<td><img src="${base}/resources/images/none.jpg"/></td>
					<td><label>${order.commodity.commodityname}</label><br/><label>${order.commoditycount*order.commodity.commodityprice}</label> </td>
				</tr>
			</c:forEach>
			<tr>
				<td align="right"><a href="${base}/selectOrder?pageNum=${pageNum-1}&maxPage=${maxPage}">上一页</a>
				${pageNum}/${maxPage}
				<a href="${base}/selectOrder?pageNum=${pageNum+1}&maxPage=${maxPage}">下一页</a></td>
			</tr>
			<tr>
				<td align="left"><input type="checkbox" onclick="change1(this)"/></td>
				<td align="right"><input type="button" value="确定收货" onclick="submit()"></td>
			</tr>
		</table>
	</div>
	
</body>
</html>